<template>
  <div class="components-container">
    <!-- 详情 -->
    <sweet-modal ref="info" class="dialog" :sweetModalMaxWidth="maxWidth">
      <h3>{{title}}</h3>
      <div style="overflow:auto;">
        <fieldset class="layui-elem-field layui-field-title">
          <legend style="font-weight: bold;">死者基本信息</legend>
          <!-- <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">逝者类型</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPTYPES" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline" style="width:575px;margin-right:0px;">
                <label class="layui-form-label">填报单位</label>
                <div class="layui-input-inline ">
                  <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入单位" v-model="prpData.PRPREPORTUNITDESC" readonly></el-input>
                </div>
            </div>
          </div> -->
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">逝者姓名</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPDEADNAME" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者性别</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPDEADSEX" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者年龄</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPDEADAGE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件类型</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPCARNOTYPE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline" style="width:575px;margin-right:0px;">
              <label class="layui-form-label">证件号码</label>
              <div class="layui-input-inline ">
                <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入证件号码"
                  v-model="prpData.PRPCARDNO" readonly></el-input>
              </div>
            </div>
          </div>

          <div class="layui-inline-item">
            <div class="layui-inline" style="width:600px;margin-right:0px;">
              <label class="layui-form-label">户籍地址</label>
              <div class="layui-input-inline ">
                <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入户籍地址"
                  v-model="prpData.PRPDETAILADDRESS" readonly></el-input>
              </div>
            </div>
          </div>

          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">死亡原因</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPCAUSA" readonly></el-input>
              </div>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPCAUSASON" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">死亡日期</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPDEATHDATE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">出生日期</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPBIRTHDAY" readonly></el-input>
              </div>
            </div>
          </div>

          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">家属姓名</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPLINKMAN" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">证件类型</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPLINKCARDNOTYPE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline" style="width:575px;margin-right:0px;">
              <label class="layui-form-label">证件号码</label>
              <div class="layui-input-inline ">
                <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" v-model="prpData.PRPLINKCARDNO"
                  readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">逝者关系</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPRELATION" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系电话</label>
              <div class="layui-input-inline ">
                <el-input v-model="prpData.PRPLINKPHONE" readonly></el-input>
              </div>
            </div>
            <div class="layui-inline">
              <label class="layui-form-label">联系地址</label>
              <div class="layui-input-inline ">
                <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入联系地址"
                  v-model="prpData.PRPLINKADDRESS" readonly></el-input>
              </div>
            </div>
          </div>
          <!-- <div class="layui-form-item">
            <div class="layui-inline" style="width:600px;margin-right:0px;">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-inline backcolor">
                <el-input class="longertext" :autosize="{ minRows: 2, maxRows: 8}" placeholder="请输入备注"
                  v-model="prpData.PRPADUITREMARK" readonly></el-input>
              </div>
            </div>
          </div> -->
        </fieldset>
      </div>
      <div class="layui-form-item btnCenter">
        <el-button @click="closeDialog">取消</el-button>
      </div>
    </sweet-modal>
  </div>
</template>

<style rel="stylesheet/scss" lang="scss" scoped>
  @import "src/styles/common.scss";

  .el-button+.el-button {
    margin-left: 0;
  }

  .longertext {
    width: 450px;
  }

  .sweet-btn {
    margin-top: 20px;
  }

</style>
<script>
  import apiBase from "@/api/apiBase.js";
  import sweetModal from "@/components/sweetModal";
  import {
    manage
  } from "@/mixins/managePage.js";
  import {
    formatDate,
    timeStringToDate
  } from "@/utils/date.js";
  export default {
    mixins: [manage],
    data() {
      return {
        maxWidth: 700,
        order: null,
        prpData: {},
        xblx: [],
        cause: [],
      };
    },
    methods: {
      open(order, id) {
        this.order = order
        switch (this.order) {
          case '详情':
            this.title = "预约详情";
            this.dataInfo(id);
            this.$refs.info.open();
            break;
          default:
        }
      },
      //登记详情
      dataInfo(id) {
        let Data = {
          PRPID: id
        };
        apiBase.DoService(
          Data,
          apiBase.getApiAdress().Reserve.DetailPhoneReserve,
          res => {
            this.prpData = res.data.content
            this.xblx.forEach(item => {
              if (this.prpData.PRPDEADSEX === item.CODNAME) {
                this.prpData.PRPDEADSEX = item.CODALIAS
              }
            })
            this.cause.forEach(item => {
              if (this.prpData.PRPCAUSA === item.value) {
                this.prpData.PRPCAUSA = item.label
              }
              item.children.forEach(itemarr => {
                if (this.prpData.PRPCAUSASON === itemarr.value) {
                  this.prpData.PRPCAUSASON = itemarr.label
                }
              })
            })
            this.prpData.PRPDEATHDATE = formatDate(this.prpData.PRPDEATHDATE,'yyyy-MM-dd')
            this.prpData.PRPBIRTHDAY = formatDate(this.prpData.PRPBIRTHDAY,'yyyy-MM-dd')
          }
        );
      },
      //数据重置
      dataRepeat() {},
      closeDialog() {
        this.$refs.info.close();
      },
      getInitData() {
        // 获取性别类型
        apiBase.DoService({},
          apiBase.getApiAdress().Registration.QueryAllCode,
          res => {
            let codeList = res.data.content;
            for (var i in codeList) {
              switch (codeList[i].CTPID) {
                case "性别类型":
                  this.xblx = codeList[i].Cods;
                  break;
                case "身份证件类型":
                  this.sfzjlx = codeList[i].Cods;
                  break;
                default:
              }
            }
          }
        );
        // 获取死亡原因
        apiBase.DoService(
          {},
          apiBase.getApiAdress().Code.GetCausa,
          res => {
            let caudata = res.data.content;
            this.cause = caudata.map(item => ({
              label: item.CAENAME,
              value: item.CAEID,
              children: item.Caus.map(itemCau => ({
                label: itemCau.CAUNAME,
                value: itemCau.CAUID
              }))
            }));
          }
        );
      },
    },
    created() {
      this.getInitData()
    },
    components: {
      sweetModal,
    },
  };

</script>
